package com.lv.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lv.mapper.TbSellerMapper;
import com.lv.model.TbSeller;
import com.lv.model.TbSellerExample;
import com.lv.service.SellerService;
import com.lv.util.ShiroUtils;
import com.lv.vo.SellerVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Service
public class SellerServiceImpl implements SellerService {

    @Autowired
    private TbSellerMapper sm;

    @Override
    public SellerVo getSellerByName(@RequestParam String sellerId) {
        TbSeller seller = sm.selectByPrimaryKey(sellerId);
        SellerVo  vo = new SellerVo();
        BeanUtils.copyProperties(seller,vo);
        return vo;
    }

    //注册

    @Override
    public void insertsell(SellerVo vo) {
        TbSeller seller = new TbSeller();
        BeanUtils.copyProperties(vo,seller);
        String salt = ShiroUtils.generateSalt(10);
        seller.setSalt(salt);
        String md5 = ShiroUtils.encryptPassword("MD5", seller.getPassword(), salt, 10);
        seller.setPassword(md5);
        sm.insertSelective(seller);

    }


}
